//
//  TXP_HeaderView.m
//  StayAwhile
//
//  Created by dllo on 16/1/27.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TXP_HeaderView.h"

@interface TXP_HeaderView ()

@property (nonatomic, strong) UIImageView *myImgView;
@property (nonatomic, strong) UITextField *searchTextField;
@end
@implementation TXP_HeaderView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame{
    
    if ([super initWithFrame:frame]) {
       
        [self createWithHeaderSubView];
    }
    return self;
}
- (void)createWithHeaderSubView{
    
    self.myImgView = [[UIImageView alloc] initWithFrame:CGRectMake(30, 30, 70, 70)];
    self.myImgView.layer.masksToBounds = YES;
    self.myImgView.layer.cornerRadius = 35;
    self.myImgView.image = [UIImage imageNamed:@"iconfont-touxiang-3.png"];
    [self addSubview:self.myImgView];
    

    self.loadBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.loadBtn setTitle:@"登录/注册" forState:UIControlStateNormal];
    self.loadBtn.titleLabel.textColor = [UIColor whiteColor];
    [self addSubview:self.loadBtn];
    [self.loadBtn addTarget:self action:@selector(clickLoadBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.loadBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo (self.myImgView.mas_right).offset(15);
        make.top.mas_equalTo (self.mas_top).offset(45);
        make.size.mas_equalTo(CGSizeMake(100, 40));
        
    }];
    
    // 搜索框
    self.searchTextField = [UITextField new];
    self.searchTextField.borderStyle = UITextBorderStyleRoundedRect;
//    self.searchTextField.backgroundColor = RGBA(83, 79, 76, 0.3);
    self.searchTextField.backgroundColor = [UIColor colorWithWhite:5 alpha:0.3];
    self.searchTextField.layer.cornerRadius = 15;
    self.searchTextField.layer.masksToBounds = YES;
    self.searchTextField.placeholder = @"搜索";
    self.searchTextField.clipsToBounds = YES;
    self.searchTextField.textColor = [UIColor lightGrayColor];
    [self addSubview:self.searchTextField];
    [self.searchTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(30);
        make.right.mas_equalTo(self.mas_right).offset(-180);
        make.top.mas_equalTo(self.mas_top).offset(130);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-20);
        
    }];
    
    
    }

- (void)clickLoadBtn:(UIButton *)btn{
    [self.headerViewdelegate clickButtonPushToLoadPage];
}

@end
